package com.pengli.mytools.ui;

import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.telephony.TelephonyManager;
import android.widget.TextView;

import com.pengli.mytools.R;
import com.pengli.mytools.ui.base.BaseActivity;

import butterknife.BindView;
import butterknife.ButterKnife;

public class OnePointLoginActivity extends BaseActivity {
    private Context mContext;

    @BindView(R.id.ac_login_phone)
    TextView ac_login_phone;

    @Override
    protected void initView() {
        setContentView(R.layout.activity_login_phone);
        ButterKnife.bind(this);
        mContext = this;

        TelephonyManager telephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            if (checkSelfPermission(Manifest.permission.READ_SMS) != PackageManager.PERMISSION_GRANTED && checkSelfPermission(Manifest.permission.READ_PHONE_NUMBERS) != PackageManager.PERMISSION_GRANTED && checkSelfPermission(Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
                // TODO: Consider calling
                //    Activity#requestPermissions
                // here to request the missing permissions, and then overriding
                //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
                //                                          int[] grantResults)
                // to handle the case where the user grants the permission. See the documentation
                // for Activity#requestPermissions for more details.
                return;
            }
        }
        String nativePhoneNumber = telephonyManager.getLine1Number();
//        String s = telephonyManager.getSimSerialNumber();
//        String deviceId = telephonyManager.getDeviceId();
        ac_login_phone.setText(nativePhoneNumber);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void setListener() {

    }
}
